<?php

namespace App\Models\admin;

use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class AdminRoleModel extends Model
{
    use HasFactory;

    protected $casts = [
        'permissions' => 'array'
    ];
    protected $table = 'admin_role';
    protected $primaryKey = 'id';

    protected $dateFormat = 'U';
    protected $fillable = ['role_name', 'permissions', 'remark'];

    protected $hidden = ['updated_at'];

    protected function createdAt(): Attribute
    {
        return Attribute::make(
            get: fn(string $value) => date("Y-m-d H:i:s", strtotime($value)),
        );
    }

}
